<%@page import="edu.tgc.security.SessionUserUtils"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<script type="text/javascript">
	$(function() {
		var $grid = $('#grid_enroll');
		var $title = '学生活动';
		var $baseUrl = 'teaching/enroll';
		$grid.datagrid({
			title : $title + '列表',
			url : $baseUrl + '/page?sort=endTime,desc&creator.id=<%=SessionUserUtils.getSysUser().getId().toString()%>',
			idField : 'id',
			fitColumns:true,
			striped : true,
			pagination : true,
			pageSize : 50,
			pageList : [ 50, 100, 200 ],
			dialog : {
				url : $baseUrl,
				name : $title,
				search : {
					width : 600,
					height : 320,
					name : '查询',
					url : 'search',
					buttons : [ $.dialog.buttons.search,$.dialog.buttons.close ]
				},
				create : {
					width : 500,
					height : 420
				},
				update : {
					width : 500,
					height : 420
				}
			},
			columns : [ [ {
				field : 'id',
				title : '编号',
				width : 250,
				hidden : true
			} , {
				field : 'name',
				title : '名称',
				width : 200
			},{
				field : 'dept',
				title : '适用范围',
				width : 200,
				formatter : function(value,row){
					return value==undefined?'':value.name;
				}
			},{
				field : 'endTime',
				title : '结束时间',
				width : 200
			},{
				field : 'creator',
				title : '创建者',
				width : 200,
				formatter : function(value,row){
					return value==undefined?'':value.name;
				}
			},{
				field : 'comment',
				title : '说明',
				width : 600
			} ] ],
			toolbar : [$.crudgrid.buttons.create,$.crudgrid.buttons.update,$.crudgrid.buttons.remove, '-',{
				text	: '导出',
				iconCls	: 'icon-print',
				handler:function(){
					row=$.crudgrid.getGrid(this).datagrid('getSelected');
					if(row==null){
						$.messager.alert('提示','请选择要导出的活动记录','info');
						return;
					}
					window.location = "teaching/participant/exportExcel?enrollId=" +row.id ;
				}
			},'-', $.crudgrid.buttons.refresh,'-' ],
	        view: detailview,               //是否是有“+”的列
	        detailFormatter: function (index, row) {                                                       //对“+”的详细设置
	        	return '<div style="padding:2px"><table class="ddv" id=ddv'+index+'></table></div>';
	        },
	        onExpandRow: function (index, row) {
	        	var ddv = $(this).datagrid('getRowDetail',index).find('table.ddv');
	        	ddv.datagrid({
	                url: 'teaching/participant/participantPage?sort=creator.cade.name&id=' + row.id,
	                //url:'taskPage?id='+row.id,
	                title:'报名记录列表',
	                fitColumns:true,
	                singleSelect:true,
	                fit  : false,
	                rownumbers:true,
	                autoRowHeight: true,
	                striped : true,
	                loadMsg:'',
	                height:'auto',
	                //sortName: 'createTime',             //排序列名
	                //sortOrder: 'asc',
					columns:[[
						 {
								field : 'id',
								title : '编号',
								width : 250,
								hidden : true
							} ,{
								field : 'banji',
								title : '班级',
								width : '200',
								formatter:function(value,row){
									return row.student==undefined?'':row.student.banji.name;
								}
							}, {
								field : 'idNo',
								title : '身份证号码',
								width : 200 ,
								formatter : function(value,row){
									return row.student==undefined?'':row.student.idNo;									
								}
							}, {
								field : 'student',
								title : '姓名',
								width : 100,
								formatter:function(value,row){
									return value==undefined?'':value.name;
								}
							},{
								field : 'cost',
								title : '报名费(元)',
								width : 100
							},{
								field : 'creator',
								title : '经手人',
								width : 100,
								formatter : function(value,row){
									return value==undefined?'':value.name;
								}
							},{
								field:'createTime',
								title:'报名时间',
								width:150
							},{
								field : 'comment',
								title : '说明',
								width : 200
							}
					]],
					onResize:function(){
			              $grid.datagrid('fixDetailRowHeight',index);
			        },
			        onLoadSuccess:function(){
			        	setTimeout(function(){
			                $grid.datagrid('fixDetailRowHeight',index);
			                $grid.datagrid('fixRowHeight',index);
			            },0);
			        }
			    }); //子表定义结束
			    $grid.datagrid('fixDetailRowHeight',index);
	     	}//展开行方法结束 

		});

	});
</script>
<table id="grid_enroll">

</table>